package com.archer.data.model;

import java.util.List;

/**
 * 分页对象
 */
public class PageObject<T> {
    private int pageSize = 25;
    private int page = 1;
    private int total = 0;
    private List<T> list;

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    /**
     * 分页时取第一条记录
     *
     * @return
     */
    public int getStartCol() {
        return (page - 1) * pageSize + 1;
    }

    /**
     * 取分页时的最后一记录
     *
     * @return
     */
    public int getEndCol() {
        return (page - 1) * pageSize + 1 + pageSize;
    }

    /**
     * 取MYSQL的limit 1,2
     *
     * @return
     */
    public String getLimitStr() {
        int start = (page - 1) * pageSize;
        return " limit " + start + "," + pageSize;
    }
}
